//
//  MainProbablyView.swift
//  MakeMoney
//
//  Created by Fan ZhiQiang on 2025/4/7.
//

import SwiftUI

struct MainProbablyView: View {
    @Bindable var pathStore: PathStore
    let chooseNum: Int
    @State private var lotterys: [Lottery] = []
    
    var body: some View {
        HStack {
            Button("查看时间间隔") {
                var lott: Lottery?
                for lottery in lotterys {
                    if let lot = lott {
//                        print("lot1 :" + lot.dateStr)
//                        print("lot2 :" + lottery.dateStr)
//                        print(lottery.date.distance(to: lot.date))
                        let components = Calendar.current.dateComponents([.day], from: lottery.date, to: lot.date)
                        if let day = components.day {
                            if day == 2 || day == 3 {
                                print(day)
                            }
                        }
                        
                    }
                    lott = lottery
                }
            }
        }
        List(lotterys) { lottery in
            VStack {
                Text(lottery.dateStr)
            }
        }
        .onAppear {
            lotterys = getLotterysWith(chooseNum: chooseNum)
        }
        .navigationTitle("\(chooseNum)的概率")
        .navigationBarTitleDisplayMode(.inline)
    }
}

#Preview {
    MainProbablyView(pathStore: .init(), chooseNum: 1)
}


class MainProbablyPath: PathName {}
